import { randomTxtLibrary } from "../../../utils";
import { host } from "../../global.config";
import { AddTemplateConfigEntity } from "../../test.entity";

const title = `自动化测试库-新建用例${randomTxtLibrary('number', 1)}`;
export const TesthubLibrariesCasesConfig: AddTemplateConfigEntity = {
  title: 'Testhub模块添加测试库用例',
  pageUrl: `${host.url}/testhub/libraries`,
  dialogTitle: '新建用例',
  screenshotName: 'testhub_add_cases_tests',
  btnGroup: [
    {
      type: 'click',
      name: 'nav',
      selector: '.nav-link span:has-text("例管")',
      delay: 2000,
    }
  ],
  operation: {
    type: 'click',
    name: 'addLibrariesBut',
    selector: 'button:has-text("新建用例")',
  },
  from: [
    {
      type: 'fill',
      name: 'title',
      selector: 'input[name="title"]',
      label: '标题',
      value: title,
      err_msg: ['用例标题不能为空'],
    },
    {
      type: 'click',
      name: 'okBtn',
      selector: 'button:has-text("保存")',
    },
  ],
  testPage: {
    btnGroup: [
      {
        type: 'click',
        name: 'sortBtn',
        selector: 'a[thytooltip="排序"]',
      },
      {
        type: 'click',
        name: 'create_at',
        selector: '.action-menu-item .name:has-text("创建时间")',
      },
    ],
    table: {
      selector: 'table',
      result: [
        {label: '标题', value: title}
      ],
    },
  },
};
